<?php
    include("./dbconn.php");

    $user = $_GET["user"];
    $pw = $_GET["pw"];

    $sql = "select * from login_register where user='$user'";

    $result = $conn->query($sql);

    if($result->num_rows > 0){
        $data['code'] = 1;
        $data['msp'] = '用户名已被占用';
    }else{
        $sql = "insert into login_register (user, pw) values ('$user', '$pw')";
        if($conn->query($sql)){
            $data['code'] = 0;
            $data['msp'] = "注册成功";
        }else{
            $data["code"] = 2;
            $data["msp"] = '注册失败';
        }
    }
    echo json_encode($data);

?>